package org.tulkas.http.headers;

import org.tulkas.http.headers.CacheControls.ResponseCacheControls;

/**
 * Standard Http request headers.
 * Default values for every header element is null, if null is set the element is not include in the http message.
 * For header reference, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">W3 Http protocol section 14</a>
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
public class ResponseHeaders extends HttpHeaders {
	//static values for typical headers
	public static final MediaTypes MEDIA_TYPEs = MediaTypes.TYPICAL;
	public static final ContentEncodings CONTENT_ENCODINGs = ContentEncodings.TYPICAL;
	public static final ResponseCacheControls CACHE_CONTROLs = CacheControls.RESPONSE;

	/**
	 * Accept-Ranges header, e.g. "none"
	 */
	public String getAcceptRanges() {
		return getHeader("Accept-Ranges");
	}

	public void setAcceptRanges(String acceptRanges) {
		updateHeader("Accept-Ranges", acceptRanges);
	}

	/**
	 * Age header, e.g. "2147483648"(2^31)
	 */
	public Long getAge() {
		String str = getHeader("Age");
		if (str != null)
			return Long.parseLong(str);
		else
			return null;
	}

	public void setAge(Long age) {
		updateHeader("Age", age.toString());
	}

	/**
	 * ETag header, e.g. "b38b9-17dd-367c5dcd"
	 */
	public String getETag() {
		return getHeader("ETag");
	}

	public void setETag(String eTag) {
		updateHeader("ETag", eTag);
	}

	/**
	 * Location header, "http://localhost/redirecttarget.html"
	 */
	public String getLocation() {
		return getHeader("Location");
	}

	public void setLocation(String location) {
		updateHeader("Location", location);
	}

	/**
	 * Proxy-Authenticate header
	 */
	public String getProxyAuthenticate() {
		return getHeader("Proxy-Authenticate");
	}

	public void setProxyAuthenticate(String proxyAuthenticate) {
		updateHeader("Proxy-Authenticate", proxyAuthenticate);
	}

	/**
	 * Server header, e.g. "Microsoft-IIS/5.0"
	 */
	public String getServer() {
		return getHeader("Server");
	}

	public void setServer(String server) {
		updateHeader("Server", server);
	}

	/**
	 * Vary header, e.g. "Date"
	 */
	public String getVary() {
		return getHeader("Vary");
	}

	public void setVary(String vary) {
		updateHeader("Vary", vary);
	}

	/**
	 * WWW-Authenticate header
	 */
	public String getWWWAuthenticate() {
		return getHeader("WWW-Authenticate");
	}

	public void setWWWAuthenticate(String wWWAuthenticate) {
		updateHeader("WWW-Authenticate", wWWAuthenticate);
	}

	/**
	 * Retry-After header, e.g. "Tue, 11 Jul 2000 18:23:51 GMT" or "60"
	 */
	public String getRetryAfter() {
		return getHeader("Retry-After");
	}

	public void setRetryAfter(String retryAfter) {
		updateHeader("Retry-After", retryAfter);
	}
}
